var express = require('express');
var router = express.Router();
var moment = require('moment');
const wechatApi = require('utils/wechat_api.js');

/* GET users listing. */
router.get('/time', function(req, res, next) {
  
  var callback = req.query.callback;
  // res.send(moment().format('YYYY-MM-DD HH:mm:ss'))
  // January 3,2017 16:48:49
  res.send(callback+'("'+moment().format('MMMM DD,YYYY HH:mm:ss')+'")');
});
var cache = {};
router.get('/getjsconfig', function(req, res, next) {
  var url = req.query.url;

  var param = {
   debug: false,
   jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage','hideMenuItems'],
   url: url
  };
  wechatApi.getJsConfig(param, function(err,result){
    if(err){
      res.send({
        err:err
      });
    }else {
      res.send(result);
    }
  });
});

module.exports = router;
